﻿namespace UnitFundProfitability.BusinessLogicTest
{
	using System;
	using Microsoft.VisualStudio.TestTools.UnitTesting;
	using UnitFundProfitability.BusinessLogic;

	/// <summary>
	/// This is a test class for Manager_FundSnapshotTest and is intended
	/// to contain all Manager_FundSnapshotTest Unit Tests.
	/// </summary>
	[TestClass()]
	public class Manager_FundSnapshotTest
	{
		private TestContext testContextInstance;

		/// <summary>
		/// Gets or sets the test context which provides
		/// information about and functionality for the current test run.
		/// </summary>
		/// <value>The test context.</value>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}

			set
			{
				testContextInstance = value;
			}
		}

		/// <summary>
		/// A test for FundSnapshot Constructor.
		/// </summary>
		[TestMethod()]
		[DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
		public void Manager_FundSnapshotConstructorTest()
		{
			Exception exception = null;
			try
			{
				Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
			}
			catch (Exception ex)
			{
				exception = ex;
			}
			Assert.IsNull(exception);
		}

		/// <summary>
		/// A test for UpdateWithExpenditureOperation.
		/// </summary>
		[TestMethod()]
		[DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
		public void UpdateWithExpenditureOperationTest()
		{
			Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
			Income income = new Income();
			income.MoneyAmount = 4;
			income.UnitsAmount = 2;
			income.Operation = new Operation();
			target.UpdateWithIncomeOperation(income);
			Expenditure expenditure = new Expenditure();
			expenditure.MoneyAmount = 3;
			expenditure.UnitsAmount = 1;
			target.UpdateWithExpenditureOperation(expenditure);
			Assert.AreEqual(1, target._incomes[0].UnitsExpenditureAmount);
		}

		/// <summary>
		/// A test for UpdateWithIncomeOperation.
		/// </summary>
		[TestMethod()]
		[DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
		public void UpdateWithIncomeOperationTest()
		{
			Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
			Income income = new Income();
			income.MoneyAmount = 4;
			income.UnitsAmount = 2;
			income.Operation = new Operation();
			target.UpdateWithIncomeOperation(income);
			Assert.IsTrue(target._incomes.Count > 0);
			Assert.AreEqual(income.MoneyAmount, target._incomes[0].MoneyAmount);
			Assert.AreEqual(income.UnitsAmount, target._incomes[0].UnitsAmount);
		}

		/// <summary>
		/// A test for MarkdownRate.
		/// </summary>
		[TestMethod()]
		[DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
		public void MarkdownRateTest()
		{
			Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
			decimal expected = 125.346M;
			decimal actual;
			target.MarkdownRate = expected;
			actual = target.MarkdownRate;
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		/// A test for PossibleMoneyExpenditure.
		/// </summary>
		[TestMethod()]
		[DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
		public void PossibleMoneyExpenditureTest()
		{
			Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
			Income income = new Income();
			income.MoneyAmount = 4;
			income.UnitsAmount = 2;
			income.Operation = new Operation();
			target.UpdateWithIncomeOperation(income);
			Expenditure expenditure = new Expenditure();
			expenditure.MoneyAmount = 2;
			expenditure.UnitsAmount = 1;
			target.UpdateWithExpenditureOperation(expenditure);
			target.MarkdownRate = 0.015M;
			target.UnitPrice = 3;
			target.UnitFund = new UnitFund();
			decimal actual = target.PossibleMoneyExpenditure;
			Assert.AreEqual(2.83085M, actual);
		}

		/// <summary>
		/// A test for UnitPrice.
		/// </summary>
		[TestMethod()]
		[DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
		public void UnitPriceTest()
		{
			Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
			decimal expected = 123.456M;
			decimal actual;
			target.UnitPrice = expected;
			actual = target.UnitPrice;
			Assert.AreEqual(expected, actual);
		}

		/// <summary>
		/// A test for Date.
		/// </summary>
		[TestMethod]
		[DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
		public void DateTest()
		{
			Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
			DateTime expected = DateTime.Now;
			target.Date = expected;
			Assert.AreEqual(expected, target.Date);
		}

		/// <summary>
		/// A test for UnitFund.
		/// </summary>
		[TestMethod]
		[DeploymentItem("UnitFundProfitability.BusinessLogic.dll")]
		public void UnitFundTest()
		{
			UnitFund expectedUnitFund = new UnitFund();
			expectedUnitFund.FundId = Guid.NewGuid();
			expectedUnitFund.FundName = "FundName";
			expectedUnitFund.CompanyId = Guid.NewGuid();
			expectedUnitFund.MarkdownPeriod = 365;
			Manager_Accessor.FundSnapshot target = new Manager_Accessor.FundSnapshot();
			target.UnitFund = expectedUnitFund;
			Assert.AreEqual(expectedUnitFund.FundId, target.UnitFund.FundId);
			Assert.AreEqual(expectedUnitFund.FundName, target.UnitFund.FundName);
			Assert.AreEqual(expectedUnitFund.CompanyId, target.UnitFund.CompanyId);
		}
	}
}
